import http from '@/http/api.js'

export const getData = (data) => {
  return http.request({
    url: 'http://127.0.0.1:9090/user/users',
    method: 'post',
    data
  })
}

export const register = (data) => {
  return http.request({
    url: 'http://127.0.0.1:9090/register',
    method: 'post',
    data
  })
}

export const login = (data) => {
  return http.request({
    url: 'http://127.0.0.1:9090/login',
    method: 'post',
    data
  })
}
export const updateUser = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/user/update`,
    method: 'put',
    data
  })
}
export const updateChat = (id, data) => {
  return http.request({
    url: `http://127.0.0.1:9090/chat/${id}`,
    method: 'post',
    data
  })
}

// 判断用户密码
export const checkPassword = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/user/check`,
    method: 'post',
    data
  })
}

export const updateDiary = (id, data) => {
  return http.request({
    url: `http://127.0.0.1:9090/diary/${id}`,
    method: 'post',
    data
  })
}

export const addDiary = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/diary/add`,
    method: 'post',
    data
  })
}

export const getCarts = () => {
  return http.request({
    url: `http://127.0.0.1:9090/carts/selectAll`,
    method: 'get',
  })
}
export const deleteCart = (id) => {
  return http.request({
    url: `http://127.0.0.1:9090/carts/delete/${id}`,
    method: 'delete',
  })
}
export const addCart = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/carts/add`,
    method: 'post',
    data
  })
}

export const getPaper = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/paper/get`,
    method: 'post',
    data
  })
}

export const getQuestion = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/question/get`,
    method: 'post',
    data
  })
}

export const getDiary = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/diary/get`,
    method: 'post',
    data
  })
}

export const addExam = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/exam`,
    method: 'post',
    data
  })
}

export const getExam = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/exam/get`,
    method: 'post',
    data
  })
}

export const addHealth = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/health/add`,
    method: 'post',
    data
  })
}

export const getHealth = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/health/get`,
    method: 'post',
    data
  })
}


export const updateHealth = (id, data) => {
  return http.request({
    url: `http://127.0.0.1:9090/health/${id}`,
    method: 'post',
    data
  })
}

export const addPeriod = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/period/add`,
    method: 'post',
    data
  })
}

export const getPeriod = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/period/get`,
    method: 'post',
    data
  })
}

export const getAdvice = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/advice/get`,
    method: 'post',
    data
  })
}

export const addAdvice = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/advice/add`,
    method: 'post',
    data
  })
}



export const getArticle = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/article/get`,
    method: 'post',
    data
  })
}


export const updatePeriod = (id, data) => {
  return http.request({
    url: `http://127.0.0.1:9090/period/${id}`,
    method: 'post',
    data
  })
}

export const deleteDiary = (id) => {
  return http.request({
    url: `http://127.0.0.1:9090/diary/${id}`,
    method: 'delete',
  })
}

export const addMenu = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/menu/add`,
    method: 'post',
    data
  })
}

export const getMenu = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/menu/get`,
    method: 'post',
    data
  })
}

export const getMusic = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/music/get`,
    method: 'post',
    data
  })
}
export const getGoodsByIds = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/menu/getByIds`,
    method: 'post',
    data
  })
}
export const getUser = (id) => {
  return http.request({
    url: `http://127.0.0.1:9090/user/selectById/${id}`,
    method: 'get',
  })
}
export const getType = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/type/get`,
    method: 'post',
    data
  })
}
export const getComment = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/comment/get`,
    method: 'post',
    data
  })
}


export const addChat = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/chat`,
    method: 'post',
    data
  })
}
export const getChat = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/chat/get`,
    method: 'post',
    data
  })
}

export const addComment = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/comment`,
    method: 'post',
    data
  })
}
export const getOrder = (userId) => {
  return http.request({
    url: `http://127.0.0.1:9090/orders/selectUserPage?userId=${userId}&pageNum=1&pageSize=1000`,
    method: 'get',
  })
}
export const updateOrder = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/orders/update`,
    method: 'put',
    data
  })
}

export const getUserInfo = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/user/selectAll`,
    method: 'get',
  })
}

export const getGoods = () => {
  return http.request({
    url: `http://127.0.0.1:9090/goods/selectPage?pageNum=1&pageSize=1000`,
    method: 'get',
  })
}
export const getGoodsById = (id) => {
  return http.request({
    url: `http://127.0.0.1:9090/goods/selectById/${id}`,
    method: 'get',
  })
}
export const getGoodsAll = () => {
  return http.request({
    url: `http://127.0.0.1:9090/goods/selectAll`,
    method: 'get',
  })
}
export const addOrder = (data) => {
  return http.request({
    url: `http://127.0.0.1:9090/orders/add`,
    method: 'post',
    data
  })
}
export const getNotice = () => {
  return http.request({
    url: `http://localhost:9090/notice/selectPage?pageNum=1&pageSize=100`,
    method: 'get',
  })
}